asm
  ld sp,$C7FF
  end asm

#include "./library/pacmandelay.bas"
#include "./library/smsrnd.bas"

dim eee as uinteger at $C010
dim seed as uinteger at $C012
dim ee0 as uinteger at $C014
dim ee1 as uinteger at $C016
dim ee2 as uinteger at $C018
dim ee3 as uinteger at $C01A
dim eex as uinteger at $C01C
dim eey as uinteger at $C01E

sub boggy84putchar(txp1 as uinteger,typ1 as uinteger,tch1 as ubyte):
  poke $D800+(txp1*32+typ1) bxor %1111100000,tch1
  end sub

sub boggy84putsprite(tla1 as uinteger, txp1 as ubyte,typ1 as ubyte,tch1 as ubyte,tat1 as ubyte):
  poke $D040+tla1*4,txp1
  poke $D041+tla1*4,tch1
  poke $D042+tla1*4,tat1
  poke $D043+tla1*4,typ1
  end sub

sub boggy84putattr(typ1 as uinteger,tsc1 as ubyte,tat1 as ubyte):
  poke $D000+(typ1*2),tsc1
  poke $D001+(typ1*2),tat1
  end sub

seed=0

for ee0=0 to 31 'y
  for ee1=0 to 31 'x
    seed=smsrnd(seed)
    boggy84putchar(ee1,ee0,seed band 7)
    next:next

for ee0=0 to 31 'y
  seed=smsrnd(seed)
  boggy84putattr(ee0,0,seed)
  next

for ee0=0 to 15
  for ee1=0 to 15
    boggy84putchar(ee1+13,ee0+15,ee0*16+ee1)
    next:next


eee=0
eex=8:eey=8

do

ee0=peek($E800)
boggy84putchar(3,1,48+(int(ee0/100) mod 10))
boggy84putchar(4,1,48+(int(ee0/10) mod 10))
boggy84putchar(5,1,48+(ee0 mod 10))

ee0=peek($E801)
boggy84putchar(3,2,48+(int(ee0/100) mod 10))
boggy84putchar(4,2,48+(int(ee0/10) mod 10))
boggy84putchar(5,2,48+(ee0 mod 10))

ee0=peek($E802)
boggy84putchar(3,3,48+(int(ee0/100) mod 10))
boggy84putchar(4,3,48+(int(ee0/10) mod 10))
boggy84putchar(5,3,48+(ee0 mod 10))

ee0=peek($E803)
boggy84putchar(3,4,48+(int(ee0/100) mod 10))
boggy84putchar(4,4,48+(int(ee0/10) mod 10))
boggy84putchar(5,4,48+(ee0 mod 10))

eex=eex+((ee0 band 2)/2)-((ee0 band 1)/1)
eey=eey+((ee0 band 32)/32)-((ee0 band 16)/16)

boggy84putchar(eex,eey,eee band 127 )
seed=smsrnd(seed)
boggy84putattr(eey,0,seed)

eee=eee+1

loop

do:loop






'for ee0=0 to $1F
'  poke $d040+ee0,ee0*4
'  pacmandelay(20000)
'  next

for ee0=0 to $1F
  seed=smsrnd(seed)
  poke $d040+ee0,seed
  pacmandelay(200)
  next


do


for ee0=$13 to $13   ' $00..$1F
  seed=smsrnd(seed)
  poke $d040+ee0,seed
  for ee1=0 to 255
    poke $d040+ee0,ee1
    pacmandelay(1000)
    next
  poke $d040+ee0,seed
  next

loop





do

for eee=$D800 to $DBFF '- videoram
  seed=smsrnd(seed)
  poke eee,seed
  pacmandelay(1000)
  next

for eee=$D040 to $D05F '- spriteram
  seed=smsrnd(seed)
  poke eee,seed
  pacmandelay(10000)
  next

for eee=$D000 to $D03F '- atrributes
  seed=smsrnd(seed)
  poke eee,seed
  pacmandelay(10000)
  next



seed=smsrnd(seed):poke $E000,seed
seed=smsrnd(seed):poke $F002,seed
seed=smsrnd(seed):poke $F003,seed
seed=smsrnd(seed):poke $F004,seed
seed=smsrnd(seed):poke $F005,seed
seed=smsrnd(seed):poke $F006,seed
seed=smsrnd(seed):poke $F007,seed
seed=smsrnd(seed):poke $F016,seed
seed=smsrnd(seed):poke $F017,seed
pacmandelay(1000)

loop



'- static ADDRESS_MAP_START( jumpcoas_map, AS_PROGRAM, 8, fastfred_state )
'- AM_RANGE(0x0000, 0x7fff) AM_ROM
'- AM_RANGE(0xc000, 0xc7ff) AM_RAM
'- AM_RANGE(0xd000, 0xd03f) AM_RAM_WRITE(fastfred_attributes_w) AM_SHARE("attributesram")
'- AM_RANGE(0xd040, 0xd05f) AM_RAM AM_SHARE("spriteram")
'- AM_RANGE(0xd060, 0xd3ff) AM_RAM
'- AM_RANGE(0xd800, 0xdbff) AM_MIRROR(0x400) AM_RAM_WRITE(fastfred_videoram_w) AM_SHARE("videoram")
'- AM_RANGE(0xe000, 0xe000) AM_WRITEONLY AM_SHARE("bgcolor")
'- AM_RANGE(0xe800, 0xe800) AM_READ_PORT("DSW1")
'- AM_RANGE(0xe801, 0xe801) AM_READ_PORT("DSW2")
'- AM_RANGE(0xe802, 0xe802) AM_READ_PORT("BUTTONS")
'- AM_RANGE(0xe803, 0xe803) AM_READ_PORT("JOYS")
'- AM_RANGE(0xf000, 0xf000) AM_WRITENOP // Unused, but initialized
'- AM_RANGE(0xf001, 0xf001) AM_WRITE(nmi_mask_w)
'- AM_RANGE(0xf002, 0xf002) AM_WRITE(fastfred_colorbank1_w)
'- AM_RANGE(0xf003, 0xf003) AM_WRITE(fastfred_colorbank2_w)
'- AM_RANGE(0xf004, 0xf004) AM_WRITE(fastfred_charbank1_w)
'- AM_RANGE(0xf005, 0xf005) AM_WRITE(fastfred_charbank2_w)
'- AM_RANGE(0xf006, 0xf006) AM_WRITE(fastfred_flip_screen_x_w)
'- AM_RANGE(0xf007, 0xf007) AM_WRITE(fastfred_flip_screen_y_w)
'- AM_RANGE(0xf116, 0xf116) AM_WRITE(fastfred_flip_screen_x_w)
'- AM_RANGE(0xf117, 0xf117) AM_WRITE(fastfred_flip_screen_y_w)
'- //AM_RANGE(0xf800, 0xf800) AM_READ(watchdog_reset_r)  // Why doesn't this work???
'- AM_RANGE(0xf800, 0xf801) AM_READNOP AM_DEVWRITE("ay8910.1", ay8910_device, address_data_w)
'- ADDRESS_MAP_END
